package com.fy.fyspace.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.fy.fyspace.model.entity.LikePicture;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

/**
 * <p>
 * 图片点赞表 Mapper 接口
 * </p>
 *
 * @author fwq
 * @since 2025-06-26
 */
@Mapper
public interface LikePictureMapper extends BaseMapper<LikePicture> {

    /**
     * 修改图片点赞状态
     * @param id
     * @param status
     * @param date
     */
    @Update("update likepicture set isDelete = #{status}, updateTime = #{date} where id = #{id}")
    void updateStatus(Long id, Integer status, Date date);

    /**
     * 查询图片点赞状态
     * @param picId
     * @param userId
     * @return
     */
    @Select("SELECT * FROM likepicture WHERE picId = #{picId} AND likeUserId = #{userId} LIMIT 1")
    LikePicture selectAllStatusByPicIdAndUserId(@Param("picId") Long picId, @Param("userId") Long userId);

    /**
     * 修改图片点赞状态
     * @param value
     * @param date
     * @param id
     */
    @Update("update likepicture set isDelete = #{isDelete}, updateTime = #{date} where id = #{id}")
    void updateIsDeleteById(Integer isDelete, Date date, Long id);
}
